<html>
<header>
    <title>执行过程</title>
    <link rel="stylesheet" type="text/css" href="{$INSTALL_CSS}/style.css" />
    <link rel="stylesheet" href="__MODULE__/lib/layui-v2.5.5/css/layui.css" media="all">
    <script src="__STATIC__/plugs/layui-v2.5.6/layui.all.js" charset="utf-8"></script>
    <script language=javascript>
        function s(){
            var c = window.document.body.scrollHeight;
            window.scroll(0,c);
            }
        </script>
</header>
<body onload="s()" style="background-color: #0A0A0A">
<div style="height:100%; color: white" id = 'log'>

 </div>

<script>
    var $;
    layui.use(['layer', 'upload', 'element','jquery'], function() {
        $ = layui.$ //重点处
    });
    //记录上次的执行结果
    var logs = [];
    function myrefresh(){
        $.ajax({
            url: "/install.php/index/process",
            dataType: 'json',
            type: 'post',
            success : function(data) {
                var datas =  data.data.data;
                var code =  data.data.errcode;
                if(code>=0){
                    $(datas.log).each(function (i, e){
                        if($('.log-'+i).length == 0) {
                            let html = `<div class="log-${i}">
                                            <span>${e[1]}${e[0] == 'success' ? "成功" : ""}</span>
                                            <span>${e[2]}</span>
                                        </div>`;
                            $('#log').append(html);
                            s();
                        }
                    })
                    if(datas.status == 1) {
                        //安装完成
                        parent.location.href='/install.php/index/installSuccess';
                    }
                }
            }
        })
    }
    setInterval('myrefresh()',300);  //指定1秒刷新一次
</script>
</body>
</html>